package com.motorola.dp.jenkinsmonitor.model.util;

import java.io.IOException;
import java.io.InputStream;

public class ResponseInputStream {

    private InputStream inputStream;

    private String contentType;

    public ResponseInputStream(InputStream inputStream, String contentType) {
        this.inputStream = inputStream;
        this.contentType = contentType;
    }

    public InputStream getInputStream() {
        return inputStream;
    }

    public void setInputStream(InputStream inputStream) {
        this.inputStream = inputStream;
    }

    public void setContentType(String contentType) {
        this.contentType = contentType;
    }

    public boolean isHtml() {
        return (contentType.indexOf("html") > -1);
    }

    public static void closeQuietly(ResponseInputStream input) {
        try {
            if (input != null && input.getInputStream() != null) {
                input.getInputStream().close();
            }
        } catch (IOException ioe) {
            return;
        }
    }

}
